<%@ Page Language="C#" MasterPageFile="~/TopLevel.master" AutoEventWireup="true"
    CodeFile="ProductReview.aspx.cs" Inherits="ProductReview" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="pageContent" runat="Server">
    <asp:FormView ID="FormView1" runat="server" DataSourceID="objReview" AllowPaging="true"
        ForeColor="#0e0e6c" OnItemInserting="FormView1_ItemInserting">
        <EmptyDataTemplate>
            No reviews exist for this product. Please add a review if you have used this product.<br />
            <asp:Button ID="btnAdd" Text="Add review" CommandName="New" runat="server" />
        </EmptyDataTemplate>
        <ItemTemplate>
            <b>Product ID: </b>
            <asp:Label ID="lblProductID" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label><br />
            <b>Reviewer: </b>
            <asp:Label ID="lblReviewerName" runat="server" Text='<%# Eval("ReviewerName") %>'></asp:Label><br />
            <b>Review Date: </b>
            <asp:Label ID="lblReviewDate" runat="server" Text='<%# Eval("ReviewDate") %>'></asp:Label><br />
            <b>Rating: </b>
            <asp:Label ID="lblRating" runat="server" Text='<%# Eval("Rating") %>'></asp:Label><br />
            <b>Comments: </b>
            <asp:Label ID="lblComments" runat="server" Text='<%# Eval("Comments") %>'></asp:Label><br />
            <asp:Button ID="btnAdd" Text="Add review" CommandName="New" runat="server" />
        </ItemTemplate>
        <InsertItemTemplate>
            <table width="100%">
                <tr>
                    <td>
                        <b>Product: </b>
                    </td>
                    <td>
                        <% =Request.QueryString["ProductName"] + " (" + Request.QueryString["ProductID"] + ")"%>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Your Name: </b>
                    </td>
                    <td>
                        <asp:TextBox ID="txtReviewerName" runat="server" Text='<%# Bind("ReviewerName") %>'></asp:TextBox></td>
                </tr>
                <tr>
                    <td>
                        <b>Email Address: </b>
                    </td>
                    <td>
                        <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("EmailAddress") %>'></asp:TextBox></td>
                </tr>
                <tr>
                    <td>
                        <b>Review Date: </b>
                    </td>
                    <td>
                        <asp:Label ID="lblDate" runat="server" Text='<%# Bind("ReviewDate") %>'><% =DateTime.Now.ToLongDateString()%></asp:Label></td>
                </tr>
                <tr>
                    <td>
                        <b>Rating: </b>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddRating" runat="server" SelectedValue='<%# Bind("Rating") %>'>
                            <asp:ListItem Value="1"></asp:ListItem>
                            <asp:ListItem Value="2"></asp:ListItem>
                            <asp:ListItem Value="3"></asp:ListItem>
                            <asp:ListItem Value="4"></asp:ListItem>
                            <asp:ListItem Value="5"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Comments: </b>
                    </td>
                    <td>
                        <asp:TextBox TextMode="MultiLine" Rows="10" ID="txtComments" runat="server" Text='<%# Bind("Comments") %>'></asp:TextBox></td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Save Review" /></td>
                    <td>
                        <asp:Button ID="Button2" runat="server" CommandName="Cancel" Text="Cancel" /></td>
                </tr>
            </table>
        </InsertItemTemplate>
    </asp:FormView>
    <asp:ObjectDataSource ID="objReview" runat="server" SelectMethod="GetReviews" TypeName="Reviews"
        InsertMethod="AddReview">
        <SelectParameters>
            <asp:QueryStringParameter Name="ProductID" QueryStringField="ProductID" Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="ProductID" Type="String" />
            <asp:Parameter Name="ReviewerName" Type="String" />
            <asp:Parameter Name="EmailAddress" Type="String" />
            <asp:Parameter Name="ReviewDate" Type="String" />
            <asp:Parameter Name="Rating" Type="String" />
            <asp:Parameter Name="Comments" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
</asp:Content>
